home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: cs.vu.nl!pverkai
- From: pverkai@cs.vu.nl (Verkaik PD)
- Subject: Order of initialisation of static globals
- Nntp-Posting-Host: sloep27.cs.vu.nl
- Sender: news@cs.vu.nl
- Organization: Fac. Wiskunde & Informatica, VU, Amsterdam
- Date: Thu, 15 Feb 1996 16:11:50 GMT
- X-Newsreader: TIN [version 1.2 PL2]
- Message-ID: <DMtrnr.Mo8.0.-s@cs.vu.nl>
-
- I have the following problem.
-
- In my programme I have defined a linked list class called lnklist.
- I want to make an object O of class lnklist put itself in another lnklist
- called queues. In other words, queues is a list of lists one of which is O.
- This should happen as part of the construction of O.
-
- Queues is a static (global) object in one module. O is also a static (global)
- object, only in another module. The problem is that O's constructor is being
- called before queues' constructor. O's constructor will attempt to put O
- in queues (which happens to work), after which queues will happily initialise
- itself removing O as a member...
-
- Now, I don't have the Reference Manual handy but I remember looking this
- one up before. If I'm correct the RM says something like
-
- 'initialisation of static storage is indeterminate, however guarantees that
- the data will be initialised before use'
-
- which is clearly not the case here.
-
- I don't even understand how this rule could possibly be correct, seeing that
- it's quite simple to make two classes' constructors call each others' members.
-
-
- Anyone?
-
-
- Patrick
-